package com.google.code.twiddling.core.command.builtin;

import com.google.code.twiddling.core.command.CommandContext;
import com.google.code.twiddling.core.command.Command;
import com.google.code.twiddling.core.clp.Option;

/**
 * Grep Command wrapped OS grep
 * 
 * @author <a href="mailto:yy.young@gmail.com">Young Yang</a>
 * @create Dec 12, 2008 10:43:41 AM
 */
@Command(name = "grep")
public class GrepCommand extends OSCommand{

    @Option(name="-e", description="exp parttern")
    private String e;

    @Option(name="-s", description="string")
    private String s;


    protected String[] getUsageCommand() {
        return new String[]{"grep"};
    }

    protected String[] getHelpCommand() {
        return new String[]{"grep","--help"};
    }

    protected String[] getOSCommand(CommandContext context) {
        /* man sh
        -c string If the -c option is present, then commands are read from string.  If there
                 are arguments after the string, they are assigned to the positional param-
                 eters, starting with $0.
        */
        return new String[]{"sh", "-c", "echo " + s +  " | " + " grep " +  e};
    }

 
}
